home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / msdos / mxmenu.zip / NOVTRANS.MNU < prev    next >
Text File  |  1993-07-15  |  15KB  |  477 lines

  1. Comment
  2. ========================================================================
  3.  
  4. Novell menu to MarxMenu Translator:
  5.  
  6. Copyright 1989-92 by Marc Perkel * All rights reserved.
  7.  
  8. Usage: MARXMENU NOVTRANS <novell menu>
  9.  
  10. This program was written to translate Novell menus to MarxMenus. It is
  11. not an exact translation, but does the bulk of the work. It is up to you
  12. to edit the output file and tune the menu the way you want.
  13.  
  14. I have made no attempt to copy color information. I am not presenting
  15. selections in sorted order, but in the order in which they are defined.
  16.  
  17. If the translation is successful then your old menu will be renamed with
  18. a NOV extension.
  19.  
  20. ========================================================================
  21. EndComment
  22.  
  23. Var
  24.   Menus
  25.   MenuPtr
  26.   CommandPtr
  27.   LinePtr
  28.   ThisMenu
  29.   ThisChoice
  30.   BoxDim
  31.   VarNum
  32.   PromptLine
  33.   Out
  34.   Cap
  35.   InputAVar
  36.   NovellFileName
  37.   MarxMenuFileName
  38.   NovellTempFileName
  39.   NovFileExists
  40.   Greek
  41.   Titles
  42.   QuietMode
  43.   NovLines
  44.  
  45. ;----- Translator Messages
  46.  
  47. Const
  48.    TopMessage = "Joe Blow's Master Menu"
  49.    BottomMessage = "*-<< Acme Manufacturing Company >>-*"
  50.  
  51. ;----- If you want the Greek Column effect, set to true
  52.  
  53. Greek = False
  54.  
  55. Qualifier MenuName MenuTitle YPos XPos MenuColor MenuChoices
  56. Qualifier ChoiceName ChoiceCmd
  57.  
  58. Comment
  59. ========================================================================
  60.  
  61. This is the main body of the NovTrans Program.
  62.  
  63. ========================================================================
  64. EndComment
  65.  
  66. if not NetWorkVersion
  67.    ClearScreen
  68.    Writeln
  69.    Writeln 'This translator requires the network version of MarxMenu to Run!'
  70. endif
  71.  
  72. PreAmble
  73. GetFileNames
  74. Parse
  75. if MenuPtr = 0
  76.    Writeln
  77.    Writeln
  78.    Writeln 'Error: ' NovellTempFileName ' is not a Novell menu!
  79.    ExitMenu
  80. endif
  81. Header
  82. WriteOutMenus
  83. Footer
  84.  
  85. ClearScreenFirst Off
  86. Writeln
  87.  
  88. if QuietMode
  89.    Execute 'MARXCOMP.EXE ' + MarxMenuFileName + ' /U'
  90. else
  91.    Execute 'MARXCOMP.EXE ' + MarxMenuFileName
  92. endif
  93.  
  94. if ReturnCode = 0
  95.    Writeln
  96.    Writeln 'Menu Translation Sucessful!'
  97.    Writeln
  98.    if not NovFileExists and not QuietMode
  99.       Writeln 'Renaming ' NovellTempFileName ' to ' ForceExtension(NovellTempFileName,'NOV')
  100.       FileRename(NovellTempFileName,ForceExtension(NovellTempFileName,'NOV'))
  101.       Writeln 'Renaming ' MarxMenuFileName ' to ' NovellTempFileName
  102.       FileRename(MarxMenuFileName,NovellTempFileName)
  103.       Writeln
  104.       Write 'Your original novell menu has been renamed to: '
  105.       Writeln ForceExtension(NovellTempFileName,'NOV')
  106.       Writeln
  107.    endif
  108.    Writeln 'To test your menu type MARX ' NovellFileName '.
  109. endif
  110.  
  111. ExitMenu
  112.  
  113. Comment
  114. =====================================
  115.  
  116. Subroutine area.
  117.  
  118. =====================================
  119. EndComment
  120.  
  121. ;----- Initilize Variables and Environment
  122.  
  123. Procedure PreAmble
  124.    ClearScreenOnExit Off
  125.    if UpperCase(ParamStr(3)) = 'U'
  126.       Quietmode = True
  127.       OutFile = 'NUL'
  128.    endif
  129.    StandardIO
  130.    Writeln
  131.    NovellFileName = UpperCase(ParamStr(2))
  132.    if Extension(NovellFileName) = 'MNU'
  133.       length(NovellFileName) = length(NovellFileName) - 4
  134.    endif
  135.    Usage
  136. EndProc
  137.  
  138. ;----- Proper Usage Procedure
  139.  
  140. Procedure Usage
  141.    if NovellFileName = ''
  142.       Writeln('Converts Novell menus to MarxMenus.')
  143.       Writeln
  144.       Writeln('  Usage: MarxMenu NovTrans <menu>')
  145.       ExitMenu
  146.    endif
  147. EndProc
  148.  
  149. ;----- Get File Names
  150.  
  151. Procedure GetFileNames
  152.    if pos('.',NovellFileName) = 0
  153.       if QuietMode
  154.          NovellTempFileName = ForceExtension(NovellFileName,'MNU')
  155.       else
  156.          NovellTempFileName = ForceExtension(NovellFileName,'NOV')
  157.          if ExistOnPath(NovellTempFileName) = ''
  158.             NovellTempFileName = ForceExtension(NovellFileName,'MNU')
  159.          else
  160.             NovFileExists = True
  161.          endif
  162.       endif
  163.  
  164.    endif
  165.  
  166.    NovellTempFileName = ExistOnPath(NovellTempFileName)
  167.  
  168.    if NovellTempFileName = ''
  169.       Writeln 'Error: ' NovellFileName ' does not exist!'
  170.       ExitMenu
  171.    endif
  172.  
  173.    if NovFileExists
  174.       MarxMenuFileName = ForceExtension(NovellTempFileName,'MNU')
  175.    else
  176.       MarxMenuFileName = ForceExtension(NovellTempFileName,'TMP')
  177.    endif
  178.  
  179.    ReadTextFile(NovellTempFileName,NovLines)
  180.    Writeln 'Creating ' MarxMenuFileName
  181. EndProc
  182.  
  183.  
  184. Procedure BlankLine
  185.    FileWriteln(Out,'')
  186. EndProc
  187.  
  188. ;----- Write out the MarxMenu Source Header
  189.  
  190. Procedure Header
  191.   FileAssign(Out,MarxMenuFileName)
  192.   FileCreate(Out)
  193.   BlankLine
  194.   FileWriteln(Out,'Comment')
  195.   FileWriteln(Out,'==========================================================')
  196.   BlankLine
  197.   FileWriteln(Out,'This file was converted from Novell Menu: ',NovellTempFileName)
  198.   BlankLine
  199.   FileWriteln(Out,'It should behave in a similar way to the original menu but')
  200.   FileWriteln(Out,'not necessarilly exactly the same. It will be close enough')
  201.   FileWriteln(Out,'for you to fine tune it the way you want.')
  202.   BlankLine
  203.   FileWriteln(Out,'To add a choice to a menu simply use the AddChoice command')
  204.   FileWriteln(Out,'then add the appropiate Onkey statement.')
  205.   FileWriteln(Out,'The menu will make the size adjustments accordinaly.')
  206.   BlankLine
  207.   FileWriteln(Out,'  Example:')
  208.   FileWriteln(Out,'      AddChoice("Print Console",10)')
  209.   FileWriteln(Out,'      ... ')
  210.   FileWriteln(Out,'      ... ')
  211.   FileWriteln(Out,'      OnKey Task(10)')
  212.   FileWriteln(Out,'        cd \public')
  213.   FileWriteln(Out,'        PConsole')
  214.   FileWriteln(Out,'      ...')
  215.   BlankLine
  216.   FileWriteln(Out,"If you want to change the menu's center, pass the XY")
  217.   FileWriteln(Out,"coordinates to menu's CenterStretchBox procedure.")
  218.   BlankLine
  219.   FileWriteln(Out,'   Example:')
  220.   FileWriteln(Out,'      CenterStretchBox("Menu Header",40,12)')
  221.   BlankLine
  222.   FileWriteln(Out,'This will cause the menu to center at Col 40, Row 12')
  223.   BlankLine
  224.   FileWriteln(Out,'Instead of defining the center of the box, there is a command')
  225.   FileWriteln(Out,'CornerStretchBox where the box grows down and right.')
  226.   BlankLine
  227.   FileWriteln(Out,'   Example:')
  228.   FileWriteln(Out,'      CornerStretchBox("Menu Header",8,6)')
  229.   BlankLine
  230.   FileWriteln(Out,'To control custom features, edit CUSTOM.INC and other INCLUDE Files.')
  231.   BlankLine
  232.   FileWriteln(Out,'=========================================================')
  233.   FileWriteln(Out,'EndComment')
  234.   BlankLine
  235.   FileWriteln(Out,';----- Create Variables')
  236.   BlankLine
  237.   FileWriteln(Out,'var')
  238.   FileWriteln(Out,'  NovVar')
  239.   FileWriteln(Out,'  KeepUsersInMenu')
  240.   BlankLine
  241.   BlankLine
  242.   FileWriteln(Out,';----- Here is where you add you own menu title and status line message')
  243.   BlankLine
  244.   FileWriteln(Out,'MenuTitle      = "',TopMessage,'"')
  245.   FileWriteln(Out,'StatusLineText = "',BottomMessage,'"')
  246.   BlankLine
  247.   FileWriteln(Out,';----- Load Novell look and feel routines')
  248.   BlankLine
  249.   FileWriteln(Out,'Include "CUSTOM.INC"')
  250.   if Greek then FileWriteln(Out,'Greek = True')
  251.   BlankLine
  252.   FileWriteln(Out,'KeepUsersInMenu Off  ;Change to On to keep users in menu.')
  253.   BlankLine
  254.   FileWriteln(Out,'Comment')
  255.   FileWriteln(Out,'=================================')
  256.   BlankLine
  257.   FileWriteln(Out,'MarxMenu is capable of software metering. This means that it can')
  258.   FileWriteln(Out,'limit the number of users of an application to a fixed amount.')
  259.   BlankLine
  260.   FileWriteln(Out,'  OnKey Task (2)')
  261.   FileWriteln(Out,"     |if Limit('LOTUS',6) then Return ;limit Lotus to 6 Users")
  262.   FileWriteln(Out,'     CD \PUBLIC\LOTUS')
  263.   FileWriteln(Out,'     123')
  264.   BlankLine
  265.   FileWriteln(Out,'Read the METER.INC file for more details.')
  266.   BlankLine
  267.   FileWriteln(Out,'=================================')
  268.   FileWriteln(Out,'EndComment')
  269.   BlankLine
  270.   FileWriteln(Out,"Include 'METER.INC'  ;Software Metering")
  271.   BlankLine
  272.   FileWriteln(Out,'Comment')
  273.   FileWriteln(Out,'=================================')
  274.   BlankLine
  275.   FileWriteln(Out,'In order to add menu choices conditionally you would append the')
  276.   FileWriteln(Out,'choices to the end of the array after all the default choices')
  277.   FileWriteln(Out,'are set. For Example:')
  278.   BlankLine
  279.   FileWriteln(Out,'   if InGroup("ACCOUNTING")')
  280.   FileWriteln(Out,'      AddChoice("Payroll Menu",10)')
  281.   FileWriteln(Out,'   endif')
  282.   BlankLine
  283.   FileWriteln(Out,'Here is where menus are created.')
  284.   BlankLine
  285.   FileWriteln(Out,'=================================')
  286.   FileWriteln(Out,'EndComment')
  287.   BlankLine
  288.   FileFlush(Out);
  289. EndProc
  290.  
  291.  
  292. ;----- Write out the MarxMenu Source Footer
  293.  
  294. Procedure Footer
  295.    BlankLine
  296.    FileWriteln(Out,';----- End of Menu Translation')
  297.    FileClose(Out)
  298. EndProc
  299.  
  300. ;----- Preprocess Lines
  301.  
  302. Procedure Parse
  303. Var ChoicePtr TotalLines X St St2
  304.    TotalLines = NumberOfElements(NovLines)
  305.    Writeln('Parsing Novell Menu source code ...')
  306.    MenuPtr = 0
  307.    loop(TotalLines)
  308.       if (LoopIndex Mod 10 = 0) or (LoopIndex = TotalLines)
  309.          Write Cr
  310.          Write('Processing Line # ',LoopIndex,' of ',TotalLines)
  311.       endif
  312.       if left(NovLines[LoopIndex],1) = '%'
  313.          ChoicePtr = 0
  314.          CommandPtr = 0
  315.          MenuPtr = MenuPtr + 1
  316.          Actual ThisMenu = Loc Menus[MenuPtr]
  317.          St = mid(NovLines[LoopIndex],2,255)
  318.          X = pos(',',St)
  319.          if X = 0 then X = succ(Length(St))
  320.          ThisMenu.MenuTitle = left(St,X - 1)
  321.          Trim(ThisMenu.MenuTitle)
  322.          AppendArray(Titles,UpperCase(ThisMenu.MenuTitle))
  323.          delete(St,1,X)
  324.          St2 = '       '
  325.          if MenuPtr < 10 then St2 = St2 + ' '
  326.          ThisMenu.MenuName = 'Menu' + Str(MenuPtr) + St2 + '{' + ThisMenu.MenuTitle + '}'
  327.          ThisMenu.YPos = value(NextWord(St))
  328.          ThisMenu.XPos = value(NextWord(St))
  329.          ThisMenu.MenuColor = value(NextWord(St))
  330.       else
  331.          if left(NovLines[LoopIndex],1) > ' '
  332.             CommandPtr = 0
  333.             ChoicePtr = ChoicePtr + 1
  334.             Trim(NovLines[LoopIndex])
  335.             if Mid(NovLines[LoopIndex], 2, 1) = '.'
  336.                Delete(NovLines[LoopIndex],1,2)
  337.                Trim(NovLines[LoopIndex])
  338.             endif
  339.  
  340.             ;----- Get rid of multiple spaces
  341.  
  342.             while pos('  ',NovLines[LoopIndex]) > 0
  343.                delete(NovLines[LoopIndex],pos('  ',NovLines[LoopIndex]),1)
  344.             endwhile
  345.  
  346.             ;----- Get rid of double quotes
  347.  
  348.             while pos('"',NovLines[LoopIndex]) > 0
  349.                delete(NovLines[LoopIndex],pos('"',NovLines[LoopIndex]),1)
  350.             endwhile
  351.  
  352.             ThisMenu.MenuChoices[ChoicePtr].ChoiceName = NovLines[LoopIndex]
  353.          else
  354.             if NovLines[LoopIndex] > ''
  355.                if ChoicePtr = 0
  356.                   Writeln
  357.                   Writeln 'Error in menu line: ' LoopIndex
  358.                   ExitMenu
  359.                endif
  360.                CommandPtr = CommandPtr + 1
  361.                ThisMenu.MenuChoices[ChoicePtr].ChoiceCmd[CommandPtr] = NovLines[LoopIndex]
  362.             endif
  363.          endif
  364.       endif
  365.    endloop
  366. EndProc
  367.  
  368. ;----- Create the Menu Choices Array
  369.  
  370. Procedure WriteOutMenuChoices
  371.    Writeln
  372.    Write('Translating: ' + ThisMenu.MenuName + ' ... ')
  373.    BlankLine
  374.    FileWriteln(Out,';=============[ ' + ThisMenu.MenuTitle + ' ]============*')
  375.    BlankLine
  376.    if MenuPtr > 1
  377.       FileWriteln(Out,':',Left(ThisMenu.MenuName,pred(pos(' ',ThisMenu.MenuName))))
  378.       BlankLine
  379.    endif
  380.    loop ThisMenu.MenuChoices
  381.       FileWriteln(Out,'  AddChoice("' + ThisMenu.MenuChoices[LoopIndex].ChoiceName + '",' + Str(LoopIndex) + ')')
  382.    endloop
  383.    BlankLine
  384.    FileWriteln(Out,'CenterStretchBox("' + ThisMenu.MenuTitle + '",' + Str(ThisMenu.XPos) + ',' + Str(ThisMenu.YPos) + ')')
  385.    BlankLine
  386. EndProc
  387.  
  388. ;----- Create the Onkey Statements
  389.  
  390. Procedure WriteOutOnkeyChoices
  391. var Tmp St X Y Z
  392.    loop ThisMenu.MenuChoices
  393.       Actual ThisChoice = Loc ThisMenu.MenuChoices[LoopIndex]
  394.       Tmp = ThisChoice.ChoiceName
  395.       FileWriteln(Out,'OnKey Task(' + Str(LoopIndex) + ')')
  396.       loop ThisChoice.ChoiceCmd
  397.          CommandPtr = LoopIndex
  398.          Tmp = ThisChoice.ChoiceCmd[CommandPtr]
  399.          Trim(Tmp)
  400.          if UpperCase(Tmp) = '!LOGOUT' then Tmp = '|Logoff'
  401.          if Left(Tmp,1) = '%'
  402.             delete(Tmp,1,1)
  403.             X = PosInList(UpperCase(Tmp),Titles)
  404.             if X = 0
  405.                Writeln
  406.                Writeln 'Error: Menu ' Tmp ' not Found!'
  407.                ExitMenu
  408.             endif
  409.             Tmp = '^' + Menus[X].MenuName
  410.          endif
  411.          if (pos('@',Tmp) > 0) and (Pos('@ECHO',UpperCase(Tmp)) = 0)
  412.             X = 1
  413.             while X <= length(Tmp)
  414.                while (X <= length(Tmp)) and (mid(Tmp,X,1) <> '@')
  415.                   X = X + 1
  416.                endwhile
  417.                Z[1] = mid(Tmp,X,1)
  418.                Z[2] = mid(Tmp,X + 1,1)
  419.                if (Z[1] = '@') and (((Z[2] > '0') and (Z[3] <= '9')) or (Z[2] = '"'))
  420.                   if Z[2] = '"'
  421.                      insert(' ',Tmp,X + 1)
  422.                      VarNum = 10
  423.                   else
  424.                      VarNum = ord(Z[2]) - 48
  425.                   endif
  426.                   InputAVar = mid(Tmp,X + 2,1) = '"'
  427.                   if InputAVar
  428.                      Y = X + 3
  429.                      while (mid(Tmp,Y,1) <> '"') and (Y <= length(Tmp))
  430.                         Y = Y + 1
  431.                      endwhile
  432.                      PromptLine = mid(Tmp,X + 3,Y - (X + 3))
  433.                   else
  434.                      Y = X + 1
  435.                   endif
  436.                   delete(Tmp,X,Y - X + 1)
  437.                   insert('" NovVar[' + Str(VarNum) + '] "',Tmp,X)
  438.                   if InputAVar
  439.                      FileWriteln(Out,'   |NovVar[' Str(VarNum) '] = ReadTextLine("' + PromptLine + '","",0,21)')
  440.                      FileWriteln(Out,'   |if LastKey = Esc')
  441.                      FileWriteln(Out,'   |LastKey = " "')
  442.                      FileWriteln(Out,'   |   Return                 ;Abort if ESC Pressed')
  443.                      FileWriteln(Out,'   |endif')
  444.                   endif
  445.                endif
  446.             endwhile
  447.             Tmp = '|Bat "' + Tmp + '"'
  448.             if right(Tmp,2) = '""'
  449.                length(Tmp) = length(Tmp) - 2
  450.             endif
  451.             Trim(Tmp)
  452.          endif
  453.          FileWriteln(Out,'   ' + Tmp)
  454.       endloop
  455.       BlankLine
  456.    endloop
  457. EndProc
  458.  
  459. ;----- Create the Menus
  460.  
  461. Procedure WriteOutMenus
  462.   Writeln
  463.   Loop Menus
  464.      MenuPtr = LoopIndex
  465.      Actual ThisMenu = Loc Menus[MenuPtr]
  466.      WriteOutMenuChoices
  467.      WriteOutOnkeyChoices
  468.      if MenuPtr = 1
  469.         FileWriteln(Out,'OnKey ESC')
  470.         FileWriteln(Out,'   |if not KeepUsersInMenu or NovConsoleOperator')
  471.         FileWriteln(Out,'   |   LeaveMenu')
  472.         FileWriteln(Out,'   |endif')
  473.         BlankLine
  474.      endif
  475.   EndLoop
  476. EndProc
  477.